{extend name="admin@public/base_content" /}
{block name="body">}
<body>
{include file="admin@public/common" /}
<div class="container-fluid larry-wrapper">
    <div class="row">
        <div class="col-xs-12 col-sm-12 col-md-12">
            <section class="panel panel-padding">
                <form class="layui-form layui-form-pane">
                    <div class="layui-form-item">
                        <label class="layui-form-label">产品名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="product_name" value="{$info.product_name}" jq-verify="required" jq-error=" 请输入产品名称" placeholder="请输入产品名称" class="layui-input ">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">产品分类</label>
                        <div class="layui-input-inline">
                            <select class="tpl-form-input" jq-verify="required" jq-error="请选择产品分类" lay-filter="verify" name="classify_id">
                                <option value="">请选择产品分类</option>
                                {volist name="classifyInfo" id="v"}
                                <option value="{$v.id}" {if condition="$info.classify_id == $v.id"}selected{/if}>{$v.classify_name}</option>
                                {/volist}
                            </select>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">应用领域</label>
                        <div class="layui-input-inline">
                            <select class="tpl-form-input" jq-verify="required" jq-error="请选择应用领域" lay-filter="verify" name="scope_id">
                                <option value="">请选择应用领域</option>
                                {volist name="scopeInfo" id="v"}
                                <option value="{$v.id}" {if condition="$info.scope_id == $v.id"}selected{/if}>{$v.scope_name}</option>
                                {/volist}
                            </select>
                        </div>
                    </div>

                    <div id="param">
                        <div class="layui-form-item">
                            <label class="layui-form-label">产品参数</label>
                            <button class="layui-btn" id='add_param' type="button">新增</button>
                        </div>
                        {foreach name='info.product_param' item='vo'}
                        <div class="layui-form-item">
                            <label class="layui-form-label">参数名称</label>
                            <div class="layui-input-inline">
                                <input name="product_param[{$key}][name]" value="{$vo.name}" placeholder="请输入" class="layui-input " type="text"></div>
                            <label class="layui-form-label">参数值</label>
                            <div class="layui-input-inline" style='width: 500px;'>
                                <input name="product_param[{$key}][param]" value="{$vo.param}" placeholder="请输入" class="layui-input" type="text"></div>
                            <button class="layui-btn layui-btn-danger del_act" onclick="del_act(this)" type="button">-</button>
                        </div>
                        {/foreach}
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">产品封面</label>
                        <div class="layui-input-block">
                            <input type="file" name="image" class="layui-upload-file" id="upload_one">
                            <input type="hidden" name="surface_image" value="{$info.surface_image|default=''}" jq-error="请上传产品封面" error-id="img-error">
                            <p id="img-error" class="error"></p>
                        </div>
                        {notempty name="info.surface_image"}
                        <div class="layui-input-block">
                            <div class="imgbox"><img src="{$info.surface_image}" alt="..." class="img-thumbnail"></div>
                        </div>
                        {/notempty}
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">产品展示图</label>
                        <div class="layui-input-block">
                            <div id="uploader" class="wu-example">
                                <div class="queueList">
                                    <div id="dndArea" class="placeholder">
                                        <div id="filePicker"></div>
                                        <p>或将照片拖到这里，单次最多可选300张</p>
                                    </div>
                                </div>
                                <div class="statusBar" style="display:none;">
                                    <div class="progress">
                                        <span class="text">0%</span>
                                        <span class="percentage"></span>
                                    </div>
                                    <div class="info"></div>
                                    <div class="btns">
                                        <div id="filePicker2"></div>
                                        <div class="uploadBtn">开始上传</div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-input-block" id="webupload_hidden_img_show">
                        {foreach name='info.pics' item='vo'}
                        <div style="float: left">
                            <img src="{$vo}" width="150px" class="img-thumbnail img_show">
                            <div style="text-align: center;cursor: pointer;" onclick="del(this)" id="{$info.id}" key="{$key}" class="webupload_img_del">删除</div>
                        </div>
                        {/foreach}
                    </div>
                    <div id="webupload_hidden_input">
                        {foreach name='info.pics' item='vo'}
                        <input type="hidden" name="pics[{$key}]" value="{$vo}">
                        {/foreach}
                    </div>

                    <div class="layui-form-item ">
                        <label class="layui-form-label">产品介绍</label>
                        <div class="layui-input-block">
                            <textarea name="content" placeholder="请输入产品介绍" class="layui-textarea">{$info.content|default=''}</textarea>
                        </div>
                    </div>

                    <div class="layui-form-item" pane>
                        <label class="layui-form-label">显示状态</label>
                        <div class="layui-input-inline">
                            <input type="radio" name="status" {eq name="info.status" value="1"}checked{/eq} title="正常" value="1" checked />
                            <input type="radio" name="status" {eq name="info.status" value="2"}checked{/eq} title="禁用" value="2" />
                        </div>
                    </div>

                    <div class="layui-input-block">
                        <input type="hidden" name="id" type="hidden" value="{$info.id}">
                        <button class="layui-btn" jq-submit lay-filter="submit" jq-tab="true">立即提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </form>
            </section>
        </div>
    </div>
</div>
</body>
{/block}
{block name="script"}
<script>
    layui.use('myform');
</script>
<script src="__ADMIN__/js/jquery/jquery.min.js"></script>
<script>
    var num="{$start_act|default='1'}";
    layui.use('myform', function(){
        var form = layui.form();
        var $= layui.jquery;
        $("#add_param").click(function() {
            $("#param").append(
                "<div class='layui-form-item'>" +
                "<label class='layui-form-label'>参数名称</label>" +
                "<div class='layui-input-inline'>" +
                "<input type='text' name='product_param["+num+"][name]' value='' placeholder='请输入' class='layui-input '>" +
                "</div>" +
                "<label class='layui-form-label'>参数值</label>" +
                "<div class='layui-input-inline' style='width: 500px;'>" +
                "<input type='text' name='product_param["+num+"][param]' value='' placeholder='请输入' class='layui-input'>" +
                "</div>" +
                "<button class='layui-btn layui-btn-danger del_act'  onclick='del_act(this)' type='button'>-</button>" +
                "</div>");
            num++;
        });
    });
    function del_act(obj) {
        var $= layui.jquery;
        $(obj).parent().remove();
        num--;
    }
    function del(obj) {
        $.ajax({
            url: "picsDel",
            data: {id: $(obj).attr('id'), key: $(obj).attr('key')},
            success: function (res) {
                if (res == 200) {
                    layer.msg('已移除文件');
                    $(obj).parent().remove();
                } else {
                    layer.msg(res.msg)
                }
            }
        });
    }
</script>
{/block}